import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";

import { MarketAccount, MarketOrder } from "qqlx-core";
import { MarketAccountGateway, MarketOrderGateway } from "qqlx-core";
import { MarketAccountSchema, MarketOrderSchema } from "qqlx-cdk";

import { PgDao } from "../../lib/dao.pg.id";
import { PgDaoUUid } from "../../lib/dao.pg.uuid";

@Injectable()
export class MarketAccountDao extends PgDao<MarketAccount> {
  constructor(
    @InjectRepository(MarketAccountSchema)
    readonly repo: Repository<MarketAccount>,
  ) {
    super({
      repository: repo,
      relations_name: MarketAccountGateway.relations,
    });
  }
}

@Injectable()
export class MarketOrderDao extends PgDaoUUid<MarketOrder> {
  constructor(
    @InjectRepository(MarketOrderSchema)
    readonly repo: Repository<MarketOrder>,
  ) {
    super({
      repository: repo,
      relations_name: MarketOrderGateway.relations,
    });
  }
}
